package moni.anyou.com.view.view.my;


import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

import androidx.fragment.app.FragmentActivity;

import com.tencent.qcloud.timchat.utils.FileUtil;

import moni.anyou.com.view.R;
import moni.anyou.com.view.config.SysConfig;
import moni.anyou.com.view.view.dynamics.detail.image.HackyViewPager;
import moni.anyou.com.view.view.dynamics.detail.image.ImageDetailFragment;
import moni.anyou.com.view.widget.utils.imageload.ImageLoadUtil;

public class ShowImageActivity extends FragmentActivity {
    private static final String STATE_POSITION = "STATE_POSITION";
    public static final String EXTRA_IMAGE_INDEX = "image_index";
    public static final String EXTRA_IMAGE_URLS = "image_urls";

    private ImageView showimage;
    private int pagerPosition;
    private TextView indicator;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.show_image_detail);

        pagerPosition = getIntent().getIntExtra(EXTRA_IMAGE_INDEX, 0);
        String urls = getIntent().getStringExtra(EXTRA_IMAGE_URLS);

        showimage = (ImageView) findViewById(R.id.showimage);
       // setBitmaptoImageView("file://" + urls,   showimage, R.drawable.loading_11,
       //         R.drawable.loading_err_11, R.drawable.loading_null_11);
        Bitmap bitmap = BitmapFactory.decodeFile(FileUtil.getCacheFilePath(urls));

       // Toast.makeText(ShowImageActivity.this,"图片被点击"+ FileUtil.getCacheFilePath(urls),Toast.LENGTH_LONG).show();
        showimage.setImageBitmap(bitmap);
        indicator = (TextView) findViewById(R.id.indicator);

        CharSequence text = getString(R.string.viewpager_indicator, 1, 1);
        indicator.setText(text);

        if (savedInstanceState != null) {
            pagerPosition = savedInstanceState.getInt(STATE_POSITION);
        }


    }
    public void setBitmaptoImageView(String url, ImageView imageview,
                                     int loadingRes, int errRes, int failRes) {
        ImageLoadUtil.getInstance(this).mImageLoader.displayImage(url,
                imageview,
                ImageLoadUtil.getOptions(loadingRes, errRes, failRes));
    }


}